include ../../../libs/mixins/form
include ../../../libs/mixins/area
include ../../../libs/mixins/table
include ../../../libs/mixins/grid

.message: .list
  .list-search
    +searchArea()
      +searchForm("searchForm")(ng-submit="queryAction()")
        .row
          +form-grid("推送任务",4)
            +text("search", "key")
          +form-grid("推送对象", 4)
            +select("search", "appPackage")(ng-options="key as val for (key, val) in pushObj")
          +form-grid("状态", 4)
            +select("search", "isSent")(ng-options="key as val for (key, val) in searchStatuses")

        .row
          +form-grid("推送日期",8): .input-daterange.input-group.text-left#searchTime
            +text("search", "beginDate")
            span.input-group-addon 到
            +text("search", "endDate")
          +grid(4).btn-row
            +submit("搜索")

  .list-content
    +operateArea("")
      +primaryButton("新建推送任务")(yh-permit="MESSAGE_CREATE" ui-sref="index.messagePush.new")
    +table()(ng-table="messagePushTable")
      tr(ng-repeat="message in messagePushs | orderBy:'-createTime'")
        td(data-title="'ID'"): a(ui-sref="index.message.view({messageId: message.id})" ng-bind="message.id")
        td(data-title="'推送任务名称'" ng-bind="message.description")
        td(data-title="'推送内容'" ng-bind="message.message.content | cut:50 ")(width="25%")
        td(data-title="'推送对象'")
          span(ng-if="message.isGlobal == true") 全部
          span(ng-if="message.isGlobal == false") 部分
          span(ng-if="message.message.appPackage == 'info.yihua.manager'") 工长APP
          span(ng-if="message.message.appPackage == 'info.yihua.master'") 装修APP
          span 用户
        td(data-title="'推送时间'" ng-bind="message.appointSendTime | date: 'yyyy-MM-dd H:mm'")
        td(data-title="'状态'")
          span(ng-if="message.isSent == true") 已发送
          span(ng-if="message.isSent != true") 待发送
        td(data-title="'计划推送数'")
          span(ng-if="message.isSent == true")
            span(ng-if="message.isGlobal == true") 全部用户
            span(ng-if="message.isGlobal != true") {{message.uidList.length}}
        td(data-title="'实际推送数'")
          span(ng-if="message.isSent == true") {{message.totalCount}}
        td(data-title="'打开数'")
          span(ng-if="message.isSent == true") {{message.readCount}}
        td(data-title="'打开率'")
          span(ng-if="message.isSent == true") {{message.readCount/message.totalCount*100 | number:0}}%
        td(data-title="'操作'")(class="operate")
          a(ui-sref="index.messagePush.view({messagePushId: message.id})") 详情
          a(href="javascript:void(0)" ng-click="stop(message.id,message.disabled,$index)" ng-if="message.isSent != true")
            span(ng-if="message.disabled == false") 停止
            span(ng-if="message.disabled == true") 继续
